package servlet;

//import hbase.HadoopUtil;

import hadoop.HadoopUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/demo")
public class ServletDemo extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        // 获取参数
        String srcPath = req.getParameter("srcPath");
        String destPath = req.getParameter("destPath");

//        String username = req.getParameter("username");
//        String englishname = req.getParameter("englishname");
//        String date = req.getParameter("date");
//        String number = req.getParameter("number");
//        String semester = req.getParameter("semester");
//        String status = req.getParameter("status");

//        hadoop工具类
        HadoopUtil hadoop = new HadoopUtil();
//        hdfs 上传文件
        String obj4 = hadoop.hadoopUpload(srcPath,destPath);


        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw = resp.getWriter();
        pw.write("<h1>"+obj4);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
